<template>
	<view class="Successful" v-if="detail.pk_id">
		<view class="box">
			<view class="box-header">
				<image class="bh-img" src="../../../static/success.png" mode=""></image>
				<text>签到成功</text>
				<view class="bh-time">
					<view class="line"></view>
					<text style="padding: 0 10rpx;">{{ detail.sign_in_time || '' }}</text>
					<view class="line"></view>
				</view>
			</view>
			<view class="box-title"><text>签到信息</text></view>
			<view class="box-detail">
				<template v-for="(item, index) in detail.option_val">
					<view class="img" v-if="item.componentName == 'FormAdvert'">
						<image :src="item.value" mode="widthFix"></image>
					</view>

					<template class="img" v-else-if="item.componentName == 'tipText'">
					</template>
					<view class="bd-item" :key="index" v-else-if="item.value">
						<view class="label">{{ item.title }}：</view>
						<!-- <view class="cont" v-if="item.componentName == 'FormRadio' || item.componentName == 'FormCheckbox'">{{ checkFilter(item.value) }}</view> -->
						<show-img v-if="item.componentName == 'uploadImg'" :str="item.value"></show-img>
						<view class="cont" v-else>{{ item.value }}</view>
					</view>
				</template>
			</view>
		</view>
	</view>
</template>

<script>
	import showImg from '../../components/showImg.vue';
	export default {
		data() {
			return {
				detail: {},
				formId: null
			};
		},
		components: {
			'show-img': showImg
		},
		// computed: {
		// checkFilter(str, arr) {
		// 	return (str, arr) => {
		// 		let checkArr = (str || '').split(',');
		// 		let name = '';
		// 		console.log('checkArr',checkArr)
		// 		console.log('arr',arr)
		// 		checkArr.forEach(checkItem => {
		// 			let findStr = arr.find(item => {
		// 				return checkItem == item.id;
		// 			});
		// 			if (findStr) {
		// 				name += findStr.name + '，';
		// 			}
		// 		});
		// 		let subIndex = name.lastIndexOf('，')
		// 		if(subIndex > -1){
		// 			return name.slice(0,name.length - 1)
		// 		}else{

		// 		return name;
		// 		}
		// 	};
		// }
		// },
		onLoad(options) {
			this.formId = Number(options.formId);
			let params = {
				pk_id: this.formId
			};
			this.$loading();
			this.$resPost('GetCustomFormValInfo', params).then(res => {
				this.detail = {
					...res.data,
					option_val: JSON.parse(res.data.option_val)
				};
				this.$hide();
			});
		},
		methods: {}
	};
</script>
<style>
	page {
		height: 100%;
	}
</style>
<style lang="scss" scoped>
	@import './index.scss'
</style>
